//
//  ButtonStyle.swift
//  NaiCha
//
//  Created by 唐安坤 on 2024/7/4.
//

import SwiftUI

struct StudyButtonStyle: View {
    var body: some View {
        ScrollView {
            VStack {
                
                MyButton(event: {
                    print("-----")
                }, imageName: "sun.max.circle", title: "旋转起来")
                MyButton(event: {
                    print("*****")
                }, imageName: "sun.max.circle", title: "翻滚起来")
                MyButton(event: {
                    print("@@@@@")
                }, imageName: "sun.max.circle", title: "摇摆起来")
                
                
                Button(action: /*@START_MENU_TOKEN@*/{}/*@END_MENU_TOKEN@*/, label: {
                    VStack {
                        Text("这是一个简单按钮")
                            .foregroundStyle(Color.white)
                        Image(systemName: "mic.fill").foregroundStyle(Color.white)
                    }
                    .padding()
                    .background(.red)
                        
                })
                .padding()
                .background(.orange)
                
                Button{
                    
                }label: {
                    Text("这是一个简单按钮")
                        .foregroundStyle(Color.white)
                        .padding()
                        .background(.purple)
                        .clipShape(RoundedRectangle(cornerRadius: 25.0))
                        .padding()
                        .overlay {
                            RoundedRectangle(cornerRadius: 50).stroke(.purple, lineWidth: 5)
                        }
                }.padding()
                
                
                Button(action: /*@START_MENU_TOKEN@*/{}/*@END_MENU_TOKEN@*/, label: {
                   
                    Text("这是一个简单按钮")
                        .foregroundStyle(Color.white)
                        .padding()
                        .background(.purple)
                        .cornerRadius(25)
                        .padding()
                        .overlay {
                            RoundedRectangle(cornerRadius: 50).stroke(.purple, lineWidth: 5.0)
                        }
                        
                }).padding()
                
                Button(action: /*@START_MENU_TOKEN@*/{}/*@END_MENU_TOKEN@*/, label: {
                    Image(systemName: "mic.fill").font(Font.system(size: 40)).foregroundStyle(Color.white)
                })
                .padding()
                .background(.purple)
                .clipShape(Circle())
                
                Button{}label: {
                    HStack{
                        Image(systemName: "mic.fill")
                            .font(.title)
                            .foregroundStyle(.white)
                        Text("录音")
                            .font(.title)
                            .foregroundStyle(.white)
                    }
                }.buttonStyle(CustomBtnStyle())
                  .padding()
                  

            }
        }
        
        
        
    }
}

#Preview {
    StudyButtonStyle()
}

private struct MyButton: View {
    let event: ()->Void
    let imageName: String
    let title: String
    var body: some View {
        Button(action: event) {
            HStack{
                Image(systemName: imageName).font(.title)
                Text(title).font(.title)
            }.foregroundStyle(Color.white)
                .background(.blue)
                .clipShape(RoundedRectangle(cornerRadius: 15))
        }.buttonStyle(RotateBtnStyle())
    }
}
